<template>
    <div>
        <div class="ruleMessage" v-if="ruleMessage">
            {{ ruleMessage }}
        </div>
        <div class="e-table" style="background-color: #fff">
            <!-- 头部buttons -->
            <div class="top">
                <div class="left">
                    <div v-if="auditState.canModify">
                        <!-- <el-button
                            size="small"
                            class="btn-greenYellow"
                            @click="openNewPage('tenderList')"
                            >引入清单</el-button
                        > -->
                        <el-dropdown @command="selectPlan">
                            <el-button size="small" class="btn-greenYellow"
                                >选择计划<i class="el-icon-arrow-down el-icon--right"></i>
                            </el-button>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item :command="1">总计划</el-dropdown-item>
                                <el-dropdown-item :command="2">零星采购计划</el-dropdown-item>
                                <el-dropdown-item :command="5">月计划</el-dropdown-item>
                                <el-dropdown-item :command="3">周材采购计划</el-dropdown-item>
                                <el-dropdown-item :command="4">临时需用计划</el-dropdown-item>
                                <el-dropdown-item
                                    :command="7"
                                    v-if="tenderData.centralizedPurchasingState"
                                    >周材集采汇总</el-dropdown-item
                                >
                                <el-dropdown-item
                                    :command="8"
                                    v-if="tenderData.centralizedPurchasingState"
                                    >物资集采汇总</el-dropdown-item
                                >
                                <el-dropdown-item :command="9">物资采购计划</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                        <el-button
                            size="small"
                            class="btn-greenYellow"
                            @click="selectBaseLibrary"
                            style="margin-left: 10px"
                            v-if="
                                !$store.state.userInfo.orgInfo.orgName.includes('项目部') &&
                                !$store.state.userInfo.orgInfo.orgName.includes('经理部')
                            "
                            >选择基础库</el-button
                        >
                        <el-button size="small" class="btn-greenYellow" @click="test1" v-if="Secret"
                            >总计划</el-button
                        >
                        <el-button size="small" class="btn-greenYellow" @click="test2" v-if="Secret"
                            >零星采购</el-button
                        >
                        <el-button size="small" class="btn-greenYellow" @click="test3" v-if="Secret"
                            >物资采购计划</el-button
                        >
                        <!-- <el-button @click="save">测试保存</el-button> -->
                    </div>
                    <el-select
                        v-model="detailsDataCurDtlId"
                        placeholder="请选择包件"
                        style="width: 300px; margin-left: 10px"
                        @change="handleNodeClick"
                    >
                        <el-option
                            v-for="item in detailsData"
                            :key="item.dtlId"
                            :label="item.itemNo + ' ' + item.name"
                            :value="item.dtlId"
                        >
                        </el-option>
                    </el-select>
                </div>
            </div>
            <el-table
                :data="tableData[dtlIndex]"
                style="width: 100%; margin-bottom: 20px"
                row-key="id"
                border
                default-expand-all
                :tree-props="{
                    children: 'children',
                    hasChildren: 'hasChildren'
                }"
                :key="dtlIndex"
                :max-height="$store.state.tableHeight"
                ref="table"
                v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                @cell-click="cellClick"
            >
                <el-table-column width="120" label="操作" v-if="auditState.canModify">
                    <!--                                 :class="{
                                    'icon-delete-active-color': MouseEnterId == scope.row.dtlId
                                }" -->
                    <template slot-scope="scope">
                        <i
                            slot="reference"
                            class="el-icon-delete"
                            style="cursor: pointer; font-size: 20px"
                            @click="deleteData(scope.$index)"
                        ></i>
                    </template>
                </el-table-column>
                <el-table-column prop="type" label="物资类别" min-width="200"> </el-table-column>
                <el-table-column prop="name" label="物资名称" width="100"> </el-table-column>
                <el-table-column prop="specs" label="规格型号" width="100"> </el-table-column>
                <el-table-column prop="unit" label="计量单位" width="100"> </el-table-column>
                <el-table-column prop="texture" label="材质" width="100"> </el-table-column>
                <el-table-column prop="num" label="数量" width="150">
                    <template slot-scope="{ row }">
                        <el-input
                            v-model="row.num"
                            placeholder="请输入内容"
                            v-enterFloat2="{
                                set: row,
                                key: 'num'
                            }"
                            @input="input(row)"
                            @blur="inputblur(row, 'num')"
                            v-if="
                                Object.keys(auditState).length !== 0 &&
                                Object.values(auditState).find(item => item === true)
                            "
                            :disabled="row.dataType === 9"
                        >
                            <i
                                slot="suffix"
                                class="el-icon-tickets"
                                @click="priceHistory(row, 'numUpdateHistory')"
                                v-if="row.numUpdateHistory && row.numUpdateHistory.length !== 0"
                            ></i>
                        </el-input>
                        <span v-else>
                            {{ row.num }}
                            <i
                                class="el-icon-tickets"
                                style="margin-left: 5px"
                                v-if="row.numUpdateHistory && row.numUpdateHistory.length !== 0"
                                @click="priceHistory(row, 'numUpdateHistory')"
                            ></i>
                        </span>
                    </template>
                </el-table-column>
                <el-table-column prop="limitPrice" label="物资申报单价（元）" width="150">
                    <template slot-scope="{ row }">
                        <el-input
                            v-model="row.limitPrice"
                            placeholder="请输入内容"
                            v-enterFloat="{
                                set: row,
                                key: 'limitPrice'
                            }"
                            @input="input(row)"
                            @blur="inputblur(row, 'limitPrice')"
                            v-if="
                                Object.keys(auditState).length !== 0 &&
                                Object.values(auditState).find(item => item === true)
                            "
                            :disabled="row.dataType === 9"
                        >
                            <i
                                slot="suffix"
                                class="el-icon-tickets"
                                @click="priceHistory(row, 'limitPriceUpdateHistory')"
                                v-if="
                                    row.limitPriceUpdateHistory &&
                                    row.limitPriceUpdateHistory.length !== 0
                                "
                            ></i>
                        </el-input>
                        <span v-else>
                            {{ row.limitPrice }}
                            <i
                                class="el-icon-tickets"
                                style="margin-left: 5px"
                                v-if="
                                    row.limitPriceUpdateHistory &&
                                    row.limitPriceUpdateHistory.length !== 0
                                "
                                @click="priceHistory(row, 'limitPriceUpdateHistory')"
                            ></i>
                        </span>
                    </template>
                </el-table-column>
                <el-table-column prop="freightPrice" label="运费申报单价（元）" width="150">
                    <template slot-scope="{ row }">
                        <el-input
                            v-model="row.freightPrice"
                            placeholder="请输入内容"
                            v-enterFloat="{
                                set: row,
                                key: 'freightPrice'
                            }"
                            @input="input(row)"
                            @blur="inputblur(row, 'freightPrice')"
                            v-if="
                                Object.keys(auditState).length !== 0 &&
                                Object.values(auditState).find(item => item === true)
                            "
                            ><i
                                slot="suffix"
                                class="el-icon-tickets"
                                @click="priceHistory(row, 'freightPriceUpdateHistory')"
                                v-if="
                                    row.freightPriceUpdateHistory &&
                                    row.freightPriceUpdateHistory.length !== 0
                                "
                            ></i>
                        </el-input>
                        <span v-else>
                            {{ row.freightPrice }}
                            <i
                                class="el-icon-tickets"
                                style="margin-left: 5px"
                                v-if="
                                    row.freightPriceUpdateHistory &&
                                    row.freightPriceUpdateHistory.length !== 0
                                "
                                @click="priceHistory(row, 'freightPriceUpdateHistory')"
                            ></i>
                        </span>
                    </template>
                </el-table-column>
                <el-table-column prop="unitPrice" label="综合单价（元）" width="120">
                </el-table-column>
                <el-table-column prop="amount" label="总金额（元）" width="120"> </el-table-column>
            </el-table>
        </div>
        <!-- dialog -->
        <el-dialog :visible.sync="historyDialogVisible" width="70%">
            <el-table
                :data="priceHistoryTableData"
                style="width: 100%; margin-bottom: 20px"
                row-key="id"
                border
                default-expand-all
                :max-height="$store.state.tableHeight"
                ref="table"
                v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
            >
                <el-table-column prop="modifier" label="操作人" width="200"> </el-table-column>
                <el-table-column prop="createTime" label="核准日期" width="100"> </el-table-column>
                <el-table-column prop="originalContent" label="原数据" width="100">
                </el-table-column>
                <el-table-column prop="modifiedContent" label="核准数据" width="100">
                </el-table-column>
                <el-table-column prop="remarks" label="审核意见" width="100"> </el-table-column>
            </el-table>
            <span slot="footer" class="dialog-footer">
                <el-button @click="historyDialogVisible = false">取 消</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
// import ComTreeTable from '@/templates/table/treeTable.vue'
// import ComTreeFile from '@/templates/table/treeFile.vue'
// import applyRequest from '@/api/tender/apply.js'
// eslint-disable-next-line no-unused-vars
import { selectDataClient, openAppClient } from '@/utils/common'
// import { vueDom } from '@/utils/common.js'
import materialProvisioningRequest from '@/api/tender/materialProvisioning.js'
import { mapMutations } from 'vuex'

export default {
    props: {
        // 原单基础数据
        tenderData: {
            type: Object,
            default: function () {
                return {}
            }
        },
        // 包件数据
        detailsData: {
            type: Array,
            default: function () {
                return []
            }
        },
        // 清单数据
        tableData: {
            type: Array,
            default: function () {
                return []
            }
        },
        // 审核状态
        auditState: {
            type: Object,
            default: function () {
                return {}
            }
        }
    },
    model: {
        prop: 'tableData',
        event: 'change'
    },
    data () {
        return {
            detailsOfProposedArr: [],
            // tableData: [],
            cloneTableData: [],
            dtlId: '',
            deleteTableData: [],
            tempArr: [], //临时用来保存清单，tabledata不能直接操作
            historyDialogVisible: false,
            priceHistoryTableData: [],
            ruleMessage: '',
            Secret: false,
            detailsDataCurDtlId: '',
            selectDetailState: false
        }
    },
    computed: {
        tenderId () {
            return this.$route.query.tenderId || this.$route.query.billid
        },
        // 当前选择包件的index
        dtlIndex () {
            return this.detailsData.findIndex(item => this.dtlId === item.dtlId)
        }
    },
    watch: {
        // 包件数据
        detailsData: {
            handler (newVal) {
                // 处理数据获得包件列表
                this.getDetails()
                if (newVal.length === 0) {
                    this.$emit('change', [])
                    // this.tableData = []
                    this.dtlId = ''
                    this.detailsDataCurDtlId = ''
                } else {
                    // 如果没选择过包件，包件id就默认第一个
                    if (this.dtlId === '' && this.selectDetailState === false) {
                        this.dtlId = newVal[0].dtlId
                    } else {
                        // 寻找当前包件数据里是否有当前id（主要判断被删情况）
                        const findVal = newVal.find(item => item.dtlId === this.dtlId)
                        if (findVal) {
                            this.dtlId = findVal.dtlId
                        } else {
                            this.dtlId = ''
                        }
                    }
                }
                // if (newVal.length === 1) {
                //     setTimeout(() => {
                //         $('.el-tree-node:first')?.addClass('is-current')
                //     }, 100)
                // }
            },
            deep: true
        },
        // 包件id
        dtlId (newVal) {
            this.detailsDataCurDtlId = newVal
            if (
                newVal !== '' &&
                JSON.stringify(this.tableData[this.dtlIndex]) ===
                    JSON.stringify(this.cloneTableData[this.dtlIndex])
            ) {
                this.getData() // 获取清单数据
            }
            // 工程tableData对应的是当前table，物资、设备对应的是所有table，删除包件只应该置空对应的table，而不是所有table，上面已经将dtlId找不到就置为空，所以tableData[this.dtlIndex]是找不到的。
            // if (newVal === '') {
            //     this.tableData = []
            // }
        }
    },
    components: {
        // ComTreeTable,
        // ComTreeFile
    },
    created () {
        // this.findByApplyId() // 获取包件列表数据
    },
    mounted () {
        // vueDom(
        //     // 默认0为选中项
        //     () => {
        //         $('.el-tree-node:first')?.addClass('is-current')
        //     },
        //     () => {
        //         return false
        //         //  $('.el-tree-node:first')?.attr('class')?.includes('is-current')
        //     }
        // )
        // setTimeout(() => {
        //     $('.el-tree-node:first')?.addClass('is-current')
        // }, 1000)
        const temp = []
        document.onkeydown = e => {
            temp.push(e.keyCode)
            if (temp.length > 4) {
                temp.splice(0, 1)
            }
            if (temp.join('') === '38384040') {
                this.Secret = true
                document.onkeydown = undefined
            }
        }
    },
    methods: {
        ...mapMutations(['setSelectedInfo']),
        cellClick (row) {
            console.log('row', row)
        },
        test1 () {
            let val = [
                {
                    billId: '1552842224744198146',
                    billNo: 'SRBGWZZJH20220729001',
                    dtlId: null,
                    id: '1552842224744198146',
                    isDetailed: 0,
                    parentId: '0',
                    materialClassId: null,
                    materialClassName: null,
                    materialId: null,
                    materialName: null,
                    planQuantity: null,
                    spec: null,
                    unitPrice: null,
                    texture: null,
                    unit: null,
                    unreceiveQuantity: null,
                    timeUnit: null,
                    startTime: null,
                    endTime: null,
                    leaseTime: null,
                    purchasingUnitId: null,
                    purchasingUnitName: null
                },
                {
                    billId: '1552842224744198146',
                    billNo: 'SRBGWZZJH20220729001',
                    dtlId: '1552842354213974018',
                    id: '1552842354213974018',
                    isDetailed: 1,
                    parentId: '1552842224744198146',
                    materialClassId:
                        'a927247cb7b1-980c-724d-300a-7fdc7a5b/a92724c24cd4-989d-0646-1070-2b007ca9/5b8670ea-a890-4b20-8724-8c51239989a5',
                    materialClassName: '主要材料/其它钢材/无缝钢管',
                    materialId: '001a45e7-b355-4f63-b773-e08243762044',
                    materialName: '无缝钢管',
                    planQuantity: 40,
                    spec: 'Ф60mm',
                    unitPrice: null,
                    texture: 'a',
                    unit: 't',
                    unreceiveQuantity: 40,
                    timeUnit: null,
                    startTime: null,
                    endTime: null,
                    leaseTime: null,
                    purchasingUnitId: '129B5182-74FF-42BB-8303-D079AB272537',
                    purchasingUnitName:
                        '四川省铁路建设有限公司G4216线宁南至攀枝花段高速公路设计施工总承包ZCB1-11项目经理部'
                },
                {
                    billId: '1552842224744198146',
                    billNo: 'SRBGWZZJH20220729001',
                    dtlId: '1556477444760465410',
                    id: '1556477444760465410',
                    isDetailed: 1,
                    parentId: '1552842224744198146',
                    materialClassId:
                        'a927247cb7b1-980c-724d-300a-7fdc7a5b/a92724c24cd4-989d-0646-1070-2b007ca9/a6b4a2d0-e45f-4a50-aa37-fc812d889f47',
                    materialClassName: '主要材料/其它钢材/普通钢板',
                    materialId: '005fa754-2228-42ef-9f84-f4dd99e2330f',
                    materialName: '普通钢板',
                    planQuantity: 30,
                    spec: '34mm',
                    unitPrice: null,
                    texture: null,
                    unit: 't',
                    unreceiveQuantity: 30,
                    timeUnit: null,
                    startTime: null,
                    endTime: null,
                    leaseTime: null,
                    purchasingUnitId: '1439990096840359936',
                    purchasingUnitName:
                        '四川路桥桥梁工程有限责任公司合淮阜高速公路董铺水库大桥维修加固工程项目经理部'
                }
            ]
            // 过滤掉父级id
            val = val.filter(item => item.materialId)
            // 过滤基础和计划相同规格的物资
            val.forEach((item, index) => {
                this.tableData[this.dtlIndex]?.forEach(item2 => {
                    const valStr =
                        item.materialClassName + item.materialName + item.spec + item.unit
                    const tableStr = item2.type + item2.name + item2.specs + item2.unit
                    // console.log('valStr', valStr)
                    // console.log('tableStr', tableStr)
                    if (valStr === tableStr) {
                        // console.log('index', index)
                        delete val[index]
                        // this.clientPop('err', '你已经选择了相同规格的物资')
                    }
                })
            })
            val = val.filter(item => item !== null)
            // 前端显示需要的数据格式
            const arr = []
            val.forEach((item, index) => {
                arr.push({
                    amount: 0,
                    billId: this.tenderId,
                    changeType: 1,
                    freightPrice: 0,
                    limitPrice: 0,
                    name: '',
                    num: 0,
                    packageId: this.dtlId,
                    recordId: '',
                    specs: '',
                    texture: '',
                    type: '',
                    unit: '',
                    unitPrice: 0,
                    planDetails: '',
                    dataType: 1,
                    materialId: '',
                    materialNameId: '',
                    materialTypeId: ''
                })
                arr[index].name = item.materialName
                arr[index].specs = item.spec
                arr[index].unit = item.unit
                arr[index].type = item.materialClassName
                arr[index].texture = item.texture
                arr[index].num = item.planQuantity
                arr[index].planDetails = JSON.stringify({
                    billid: item.billId,
                    billNo: item.billNo,
                    type: 1
                })
                arr[index].materialId = item.materialId
                arr[index].materialNameId = item.billId
                arr[index].materialTypeId = item.materialClassId
            })
            this.tableData[this.dtlIndex].push(...arr)
        },
        test2 () {
            let val = [
                {
                    billId: '1554731573152772098',
                    billNo: 'SRBGWZLXCGJH20220729003',
                    dtlId: null,
                    id: '1554731573152772098',
                    isDetailed: 0,
                    parentId: '0',
                    materialClassId: null,
                    materialClassName: null,
                    materialId: null,
                    materialName: null,
                    planQuantity: null,
                    spec: null,
                    unitPrice: null,
                    texture: null,
                    unit: null,
                    unreceiveQuantity: null,
                    timeUnit: null,
                    startTime: null,
                    endTime: null,
                    leaseTime: null,
                    purchasingUnitId: null,
                    purchasingUnitName: null
                },
                {
                    billId: '1554731573152772098',
                    billNo: 'SRBGWZLXCGJH20220729003',
                    dtlId: '1554732538949988354',
                    id: '1559815971569070082',
                    isDetailed: 1,
                    parentId: '1554731573152772098',
                    materialClassId:
                        'a92724915394-8f4a-2247-3575-754cb0ea/8366c07b-9a82-4a80-9626-337b2a76a1af/10b8c980-981b-4e90-81b8-550288428a04',
                    materialClassName: '其它材料/木材/胶合板',
                    materialId: 'a99820331b56-a7a8-0247-4367-1e3a71f7',
                    materialName: '胶合板',
                    planQuantity: 1,
                    spec: null,
                    unitPrice: 1,
                    texture: '1',
                    unit: '㎡',
                    unreceiveQuantity: -2,
                    timeUnit: null,
                    startTime: null,
                    endTime: null,
                    leaseTime: null,
                    purchasingUnitId: null,
                    purchasingUnitName: null
                },
                {
                    billId: '1555093600165621762',
                    billNo: 'SRBGWZLXCGJH20220729006',
                    dtlId: '1556909564091887618',
                    id: '1559815982377791490',
                    isDetailed: 1,
                    parentId: '1555093600165621762',
                    materialClassId:
                        'a92724915394-8f4a-2247-3575-754cb0ea/a0b7dce4-4338-4c96-8882-5d5e5fa625b9',
                    materialClassName: '其它材料/其他',
                    materialId: '000ce496-e2f2-4391-a74c-24b36e48f901',
                    materialName: '输送泵软管',
                    planQuantity: 4,
                    spec: '150*3000mm',
                    unitPrice: 4,
                    texture: 'a',
                    unit: '根',
                    unreceiveQuantity: 4,
                    timeUnit: null,
                    startTime: null,
                    endTime: null,
                    leaseTime: null,
                    purchasingUnitId: null,
                    purchasingUnitName: null
                }
            ]
            // 过滤掉父级id
            val = val.filter(item => item.materialId)
            // 过滤基础和计划相同规格的物资
            val.forEach((item, index) => {
                this.tableData[this.dtlIndex]?.forEach(item2 => {
                    const valStr =
                        item.materialClassName + item.materialName + item.spec + item.unit
                    const tableStr = item2.type + item2.name + item2.specs + item2.unit
                    // console.log('valStr', valStr)
                    // console.log('tableStr', tableStr)
                    if (valStr === tableStr) {
                        // console.log('index', index)
                        delete val[index]
                        // this.clientPop('err', '你已经选择了相同规格的物资')
                    }
                })
            })
            val = val.filter(item => item !== null)
            // 前端显示需要的数据格式
            const arr = []
            val.forEach((item, index) => {
                arr.push({
                    amount: 0,
                    billId: this.tenderId,
                    changeType: 1,
                    freightPrice: 0,
                    limitPrice: 0,
                    name: '',
                    num: 0,
                    packageId: this.dtlId,
                    recordId: '',
                    specs: '',
                    texture: '',
                    type: '',
                    unit: '',
                    unitPrice: 0,
                    planDetails: '',
                    dataType: 1,
                    materialId: '',
                    materialNameId: '',
                    materialTypeId: ''
                })
                arr[index].name = item.materialName
                arr[index].specs = item.spec
                arr[index].unit = item.unit
                arr[index].type = item.materialClassName
                arr[index].texture = item.texture
                arr[index].num = item.planQuantity
                arr[index].planDetails = JSON.stringify({
                    billid: item.billId,
                    billNo: item.billNo,
                    type: 2
                })
                arr[index].materialId = item.materialId
                arr[index].materialNameId = item.billId
                arr[index].materialTypeId = item.materialClassId
            })
            this.tableData[this.dtlIndex].push(...arr)
        },
        inputblur (row, val) {
            console.log('row', row, this.tableData)
            row[val] = isNaN(parseFloat(row[val])) ? 0 : parseFloat(row[val])
        },
        priceHistory (row, arg) {
            this.historyDialogVisible = true
            this.priceHistoryTableData = row[arg]
        },
        deleteData (index) {
            this.tableData.forEach(() => {
                this.deleteTableData.push([])
            })
            if (this.tableData[this.dtlIndex][index].changeType !== 1) {
                this.tableData[this.dtlIndex][index].changeType = -1
                this.deleteTableData[this.dtlIndex].push(this.tableData[this.dtlIndex][index])
            }
            this.tableData[this.dtlIndex].splice(index, 1)
        },
        getData (dtlId = this.dtlId, dtlIndex = this.dtlIndex) {
            // console.log('getData', this.tableData, this.dtlIndex)
            // console.log('blur', this.tableData[this.dtlIndex].find(item => item.changeType !== 0) !== undefined)
            // 如果当前包件清单有数据则不查询
            // if (this.tableData[this.dtlIndex] !== undefined) return
            // 如果当前包件清单修改过则不查询
            // if (
            //     (this.tableData[this.dtlIndex] !== undefined &&
            //         this.tableData[this.dtlIndex].find(item => item.changeType !== 0) ===
            //             undefined)
            // )
            //     return
            // console.log('this.deleteTableData', this.deleteTableData)
            // if (arg !== 0) {
            //     if (
            //         this.tableData[this.dtlIndex]?.find(item => item.changeType !== 0) !==
            //             undefined ||
            //         (this.deleteTableData[this.dtlIndex] !== undefined &&
            //             this.deleteTableData[this.dtlIndex]?.length !== 0)
            //     )
            //         return
            // }
            materialProvisioningRequest.dtlListByEntity({ packageId: dtlId }).then(async res => {
                // 整个清单的数据
                if (this.tableData.length === 0) {
                    this.detailsData.forEach(() => {
                        this.tableData.push([])
                        this.cloneTableData.push([])
                    })
                }
                this.$set(this.tableData, dtlIndex, res)
                this.cloneTableData[dtlIndex] = JSON.parse(JSON.stringify(res))
                // await this.$emit('change', this.tempArr)
                this.tableData[dtlIndex].forEach(item => {
                    item.changeType = 0
                })
                this.cloneTableData[dtlIndex].forEach(item => {
                    item.changeType = 0
                })
                // console.log('getdata this.cloneTableData', this.cloneTableData)
                // 用于判断数据是否更新
                // this.cloneTableData = JSON.parse(JSON.stringify(this.tableData))
            })
        },
        input (row) {
            // 综合单价（元） = 设备申报单价+运费申报单价
            row.unitPrice = isNaN(
                parseFloat((parseFloat(row.limitPrice) + parseFloat(row.freightPrice)).toFixed(2))
            )
                ? 0
                : parseFloat((parseFloat(row.limitPrice) + parseFloat(row.freightPrice)).toFixed(2))
            // 总金额（元）=数量*综合单价
            row.amount = isNaN(
                parseFloat((parseFloat(row.unitPrice) * parseFloat(row.num)).toFixed(2))
            )
                ? 0
                : parseFloat((parseFloat(row.unitPrice) * parseFloat(row.num)).toFixed(2))
        },
        // 如果数据修改了加上changeState1
        // 比较的是每一项
        ifEdit (tableData, cloneTableData) {
            let state = false
            if (tableData === undefined && cloneTableData === undefined) return
            // 判断每条数据
            tableData.forEach(item => {
                cloneTableData.forEach(item2 => {
                    // 判断数据是否修改
                    if (
                        item.recordId === item2.recordId &&
                        JSON.stringify(item) !== JSON.stringify(item2)
                    ) {
                        // 判断数量、运费单价、物资申报单价是否修改
                        if (item.num !== item2.num) {
                            item.isUpdateNumState = true
                        } else {
                            item.isUpdateNumState = false
                        }
                        if (item.limitPrice !== item2.limitPrice) {
                            item.isUpdateLimitPriceState = true
                        } else {
                            item.isUpdateLimitPriceState = false
                        }
                        if (item.freightPrice !== item2.freightPrice) {
                            item.isUpdateFreightPriceState = true
                        } else {
                            item.isUpdateFreightPriceState = false
                        }
                        state = true
                        item.changeType = 2
                    }
                })
            })
            // 边界情况：删除数据
            if (tableData.length !== cloneTableData.length) state = true
            // 边界情况：新增数据
            if (cloneTableData.length === 0) state = true
            // 边界情况：清单没数据没修改
            if (tableData.length === 0 && cloneTableData.length === 0) state = false
            return state
        },
        // 清单验证
        tenderListRule () {
            if (this.tableData.length === 0) {
                this.ruleMessage = '请添加清单'
                this.$emit('onChangeTab', { name: 'tenderListCon' })
                return false
            }
            // 清单验证
            const ruleMessageArr = []
            if (this.tableData.length === 0) {
                return true
            }
            this.tableData.forEach((item, index) => {
                index += 1
                item.forEach((item2, index2) => {
                    index2 += 1
                    if (item2.num <= 0) {
                        ruleMessageArr.push(`包件${index}清单${index2}数量必须大于0`)
                    }
                    if (item2.limitPrice <= 0) {
                        ruleMessageArr.push(`包件${index}清单${index2}物资申报单价必须大于0`)
                    }
                    if (item2.freightPrice < 0) {
                        ruleMessageArr.push(`包件${index}清单${index2}运费申报单价必须大于等于0`)
                    }
                })
            })
            this.ruleMessage = ruleMessageArr.join(',')
            if (ruleMessageArr.length === 0) {
                return true
            } else {
                this.$emit('onChangeTab', { name: 'tenderList' })
                return false
            }
        },
        // 清单保存
        save () {
            // if (!this.tenderListRule()) return Promise.reject()
            new Promise(resolve => {
                let num = 0
                let length = this.detailsData.length
                this.detailsData.forEach(async (item, index) => {
                    // 当前清单对应的包件id
                    const dtlId = item.dtlId
                    const dtlIndex = this.detailsData.findIndex(item2 => dtlId === item2.dtlId)
                    // 是否修改数据
                    if (!this.ifEdit(this.tableData[index], this.cloneTableData[index])) {
                        length -= 1
                        return
                    }
                    const deleteTableData =
                        this.deleteTableData[index] === undefined ? [] : this.deleteTableData[index]
                    // console.log('deleteTableData', deleteTableData)
                    const tableData = [...this.tableData[index], ...deleteTableData]
                    // 更新清单
                    await materialProvisioningRequest.dtlSave(tableData)
                    await this.getData(dtlId, dtlIndex)
                    // 更新包件
                    // materialProvisioningRequest.packageCreate(this.detailsData)
                    num++
                    if (num === length) {
                        resolve()
                    }
                })
            }).then(() => {
                // // 查询清单(不需要条件判断)
                // this.getData(0)
            })
            // if (!this.ifEdit(this.tableData)) return
            // // 加上删除数据
            // const tableData = [...this.tableData, ...this.deleteTableData]
            // materialProvisioningRequest.dtlSave(tableData)
            // 包件更新计划编号、采购最高限价
            // if (this.tableData.length !== 0) {
            //     // // 转成成后端需要的计划数据
            //     // const paln = JSON.stringify(
            //     //     Array.from(
            //     //         new Set(this.tableData.map(item => item.planDetails).filter(item => item))
            //     //     ).map(item => JSON.parse(item))
            //     // )
            //     // const priceLimit = this.tableData.reduce((prev, cur) => {
            //     //     return prev + cur.amount
            //     // }, 0)
            //     // 修改包件列表的计划编号（顺带一起保存了改变的价格数据）
            //     if (paln.length !== 0) {
            //         this.detailsData.forEach(item => {
            //             if (item.dtlId === this.dtlId) {
            //                 item.changeType = 2
            //                 item.planDetails = paln
            //                 // item.priceLimit = priceLimit
            //             }
            //         })
            //     }
            // } else {
            //     this.detailsData.forEach(item => {
            //         if (item.dtlId === this.dtlId) {
            //             item.changeType = 2
            //             item.planDetails = ''
            //             // item.priceLimit = 0
            //         }
            //     })
            // }
            // materialProvisioningRequest.packageCreate(this.detailsData)
            // console.log('palnArr', JSON.stringify(palnArr))
            // tableData.forEach((item)=>{})
        },
        getDetails () {
            this.detailsOfProposedArr = []
            if (this.detailsData.length !== 0) {
                this.detailsData.forEach((value, index) => {
                    if (value.dtlId !== '') {
                        this.detailsOfProposedArr.push({
                            label: value.name,
                            index
                        })
                    }
                })
            }
        },
        test3 () {
            let val = [
                {
                    billId: '1585941756856967169',
                    billNo: 'SRBCLXCGJH20221028008',
                    dtlId: '1585942083194789890',
                    id: '1587339091369467905',
                    isDetailed: 1,
                    marketPrice: 5,
                    materialClassId:
                                'a927247cb7b1-980c-724d-300a-7fdc7a5b/0ed2465a-0f3f-466a-b608-720911c3a182/5ceb3143-0e02-4dc4-824b-e8185186e7a4',
                    materialClassName: '主要材料/土工材料/土工布',
                    materialId: '2dc436f7-e72d-49be-921d-7bacbb783d08',
                    materialName: '防渗土工布',
                    parentId: '1585941756856967169',
                    planQuantity: 20,
                    purchaseType: 4,
                    purchasingUnitId: 'ad551eff9d03-8efe-2148-9ed8-64781e1e',
                    purchasingUnitName: '四川路桥建设集团股份有限公司',
                    spec: '250g',
                    texture: '11',
                    unit: 'm2',
                    unreceiveQuantity: 20,
                    unsummarizedQuantity: null,
                    isChange: null
                }
            ]
            // 过滤掉父级id
            val = val.filter(item => item.materialId)
            // 过滤基础和计划相同规格的物资
            val.forEach((item, index) => {
                        this.tableData[this.dtlIndex]?.forEach(item2 => {
                            const valStr =
                                item.materialClassName + item.materialName + item.spec + item.unit
                            const tableStr = item2.type + item2.name + item2.specs + item2.unit
                            // console.log('valStr', valStr)
                            // console.log('tableStr', tableStr)
                            if (valStr === tableStr) {
                                // console.log('index', index)
                                delete val[index]
                                // this.clientPop('err', '你已经选择了相同规格的物资')
                            }
                        })
            })
            val = val.filter(item => item !== null)
            // 前端显示需要的数据格式
            const arr = []
            val.forEach((item, index) => {
                arr.push({
                    amount: 0,
                    billId: this.tenderId,
                    changeType: 1,
                    freightPrice: 0,
                    limitPrice: 0,
                    name: '',
                    num: 0,
                    packageId: this.dtlId,
                    recordId: '',
                    specs: '',
                    texture: '',
                    type: '',
                    unit: '',
                    unitPrice: 0,
                    planDetails: '',
                    materialId: '',
                    materialNameId: '',
                    materialTypeId: '',
                    dataType: 9,
                    planId: '',
                    planDtlId: ''
                })
                arr[index].name = item.materialName
                arr[index].specs = item.spec
                arr[index].unit = item.unit
                arr[index].type = item.materialClassName
                arr[index].texture = item.texture
                arr[index].num = item.planQuantity
                arr[index].planDetails = JSON.stringify({
                    billid: item.billId,
                    billNo: item.billNo,
                    type: 9
                })
                arr[index].materialId = item.materialId
                arr[index].materialNameId = item.billId
                arr[index].materialTypeId = item.materialClassId
                arr[index].planId = item.billId
                arr[index].planDtlId = item.dtlId
                arr[index].limitPrice = item.marketPrice
            })
            // val.forEach((item, index) => {})
            // console.log(' this.tableData', this.tableData, this.tableData[this.dtlIndex])
            this.tableData[this.dtlIndex].push(...arr)
            console.log('request', this.tableData, this.dtlIndex)
        },
        // 选择计划
        selectPlan (PlanType2) {
            if (this.dtlId === '') {
                this.clientPop('err', '请先添加包件')
                return
            }
            // 获取已选择计划id
            const SelectedIDs =
                this.tableData[this.dtlIndex] !== undefined &&
                this.tableData[this.dtlIndex].map(item => item.materialId).filter(item => item)
                    .length !== 0
                    ? this.tableData[this.dtlIndex]
                        .map(item => item.materialId)
                        .filter(item => item)
                    : []
            // PlanType2
            // console.log('SelectedIDs', SelectedIDs)
            // console.log('tenderForm', this.tenderData.tenderForm)
            let InitParamsStr = {}
            // 9 物资采购计划
            if (PlanType2 === 9) {
                InitParamsStr = {
                    parentId: 0,
                    ProcurementMethod: this.tenderData.tenderForm //招标方式
                }
                selectDataClient({
                    SelectServiceToken: '/material/purchasePlan/getPurchasePlanDtls', // 客+户端对应方法名,
                    IsSingleMode: false, // 是否单选 true 单选 false 多选
                    SelectedIDs, // 已选中id
                    InitParamsStr: JSON.stringify(InitParamsStr),
                    Title: '选择计划' // 标题
                }).then(val => {
                    // this.setSelectedInfo(val)
                    // openAppClient('/showSelectedData', '选择结果', function () {})
                    // 假数据
                    //                 let val=[
                    //     {
                    //         billId: '1585941756856967169',
                    //         billNo: 'SRBCLXCGJH20221028008',
                    //         dtlId: '1585942083194789890',
                    //         id: '1587339091369467905',
                    //         isDetailed: 1,
                    //         marketPrice: 5,
                    //         materialClassId:
                    //             'a927247cb7b1-980c-724d-300a-7fdc7a5b/0ed2465a-0f3f-466a-b608-720911c3a182/5ceb3143-0e02-4dc4-824b-e8185186e7a4',
                    //         materialClassName: '主要材料/土工材料/土工布',
                    //         materialId: '2dc436f7-e72d-49be-921d-7bacbb783d08',
                    //         materialName: '防渗土工布',
                    //         parentId: '1585941756856967169',
                    //         planQuantity: 20,
                    //         purchaseType: 4,
                    //         purchasingUnitId: 'ad551eff9d03-8efe-2148-9ed8-64781e1e',
                    //         purchasingUnitName: '四川路桥建设集团股份有限公司',
                    //         spec: '250g',
                    //         texture: '11',
                    //         unit: 'm2',
                    //         unreceiveQuantity: 20,
                    //         unsummarizedQuantity: null,
                    //         isChange: null
                    //     }
                    // ]
                    if (PlanType2 === 9 && val.some(item => item.isChange === true)) {
                        this.clientPop('err', '计划变更在进行中，请完成变更后再进行招标')
                        return
                    }
                    // 过滤掉父级id
                    val = val.filter(item => item.materialId)
                    // 过滤基础和计划相同规格的物资
                    val.forEach((item, index) => {
                        this.tableData[this.dtlIndex]?.forEach(item2 => {
                            const valStr =
                                item.materialClassName + item.materialName + item.spec + item.unit
                            const tableStr = item2.type + item2.name + item2.specs + item2.unit
                            // console.log('valStr', valStr)
                            // console.log('tableStr', tableStr)
                            if (valStr === tableStr) {
                                // console.log('index', index)
                                delete val[index]
                                // this.clientPop('err', '你已经选择了相同规格的物资')
                            }
                        })
                    })
                    val = val.filter(item => item !== null)
                    // 前端显示需要的数据格式
                    const arr = []
                    val.forEach((item, index) => {
                        arr.push({
                            amount: 0,
                            billId: this.tenderId,
                            changeType: 1,
                            freightPrice: 0,
                            limitPrice: 0,
                            name: '',
                            num: 0,
                            packageId: this.dtlId,
                            recordId: '',
                            specs: '',
                            texture: '',
                            type: '',
                            unit: '',
                            unitPrice: 0,
                            planDetails: '',
                            materialId: '',
                            materialNameId: '',
                            materialTypeId: '',
                            dataType: PlanType2,
                            planId: '',
                            planDtlId: ''
                        })
                        arr[index].name = item.materialName
                        arr[index].specs = item.spec
                        arr[index].unit = item.unit
                        arr[index].type = item.materialClassName
                        arr[index].texture = item.texture
                        arr[index].num = item.planQuantity
                        arr[index].planDetails = JSON.stringify({
                            billid: item.billId,
                            billNo: item.billNo,
                            type: PlanType2
                        })
                        arr[index].materialId = item.materialId
                        arr[index].materialNameId = item.billId
                        arr[index].materialTypeId = item.materialClassId
                        arr[index].planId = item.billId
                        arr[index].planDtlId = item.dtlId
                        arr[index].limitPrice = item.marketPrice
                    })
                    // val.forEach((item, index) => {})
                    // console.log(' this.tableData', this.tableData, this.tableData[this.dtlIndex])
                    this.tableData[this.dtlIndex].push(...arr)
                    console.log('request', this.tableData, this.dtlIndex)
                })
                return
            }
            // 7 周材集采汇总
            // 8 物资集采汇总
            if (PlanType2 === 7 || PlanType2 === 8) {
                InitParamsStr = {
                    PlanType2,
                    ProcurementMethod: this.tenderData.tenderForm
                }
            } // 总计划
            else if (PlanType2 === 1) {
                InitParamsStr = {
                    PlanType2, //计划类型
                    BusinessType: '0', //临时需用计划业务类型（0：自购，1：租赁）
                    PurchaseType: this.tenderData.centralizedPurchasingState, //总计划采购类型 0：普通采购，1：集中采购
                    IsSignContract: '1', //零星采购计划是否要签合同(0:否;1:是;)
                    ProcurementMethod: this.tenderData.tenderForm //招标方式
                }
                // console.log('InitParamsStr', InitParamsStr)
                // 零星采购计划
            } else if (PlanType2 === 2)
                InitParamsStr = {
                    PlanType2, //计划类型
                    BusinessType: '0', //临时需用计划业务类型（0：自购，1：租赁）
                    PurchaseType: '0', //总计划采购类型 0：普通采购，1：集中采购
                    IsSignContract: '1', //零星采购计划是否要签合同(0:否;1:是;)
                    ProcurementMethod: this.tenderData.tenderForm
                }
            else {
                // 其他计划
                InitParamsStr = {
                    PlanType2, //计划类型
                    BusinessType: '0', //临时需用计划业务类型（0：自购，1：租赁）
                    PurchaseType: '0', //总计划采购类型 0：普通采购，1：集中采购
                    IsSignContract: '1' //零星采购计划是否要签合同(0:否;1:是;)
                }
            }
            // this.setSelectedInfo(InitParamsStr)
            // openAppClient('/showSelectedData', '选择结果', function () {})
            console.log('InitParamsStr', InitParamsStr)
            selectDataClient({
                SelectServiceToken: '/common/planSelect', // 客+户端对应方法名,
                IsSingleMode: false, // 是否单选 true 单选 false 多选
                SelectedIDs, // 已选中id
                InitParamsStr: JSON.stringify(InitParamsStr),
                Title: '选择计划' // 标题
            }).then(val => {
                // alert(111)
                // this.setSelectedInfo(val)
                // openAppClient('/showSelectedData', '选择结果', function () {})
                // 假数据
                // let val = [
                //     {
                //         billId: '1503576787888304129',
                //         billNo: 'SRBGWZLXCGJH20220311006',
                //         dtlId: null,
                //         id: '1503576787888304129',
                //         isDetailed: 0,
                //         parentId: '0',
                //         materialClassId: null,
                //         materialClassName: null,
                //         materialId: null,
                //         materialName: null,
                //         planQuantity: null,
                //         spec: null,
                //         texture: null,
                //         unit: null,
                //         unreceiveQuantity: null
                //     },
                //     {
                //         billId: '1503576787888304129',
                //         billNo: 'SRBGWZLXCGJH20220311006',
                //         dtlId: '1503618831167975426',
                //         id: '1514525092260540417',
                //         isDetailed: 1,
                //         parentId: '1503576787888304129',
                //         materialClassId: '1492338036615155713/1492338402287161345/1492339386505760770',
                //         materialClassName: '主要材料/建筑钢材/一级钢材',
                //         materialId: '1492034813597585409',
                //         materialName: '钢材0009',
                //         planQuantity: 2,
                //         spec: '规格9',
                //         texture: '2',
                //         unit: 'T',
                //         unreceiveQuantity: 2
                //     },
                //     {
                //         billId: '1503576787888304129',
                //         billNo: 'SRBGWZLXCGJH20220311006',
                //         dtlId: '1503618831167975427',
                //         id: '1514525092260540418',
                //         isDetailed: 1,
                //         parentId: '1503576787888304129',
                //         materialClassId: '1492338036615155713/1492338402287161345/1492339386505760770',
                //         materialClassName: '主要材料/建筑钢材/一级钢材',
                //         materialId: '1492034852101296129',
                //         materialName: '钢材00010',
                //         planQuantity: 2,
                //         spec: '规格10',
                //         texture: '2',
                //         unit: 'T',
                //         unreceiveQuantity: 2
                //     }
                // ]
                if (PlanType2 === 9 && val.some(item => item.isChange === true)) {
                    this.clientPop('err', '计划变更在进行中，请完成变更后再进行招标')
                    return
                }
                // 过滤掉父级id
                val = val.filter(item => item.materialId)
                // 过滤基础和计划相同规格的物资
                val.forEach((item, index) => {
                    this.tableData[this.dtlIndex]?.forEach(item2 => {
                        const valStr =
                            item.materialClassName + item.materialName + item.spec + item.unit
                        const tableStr = item2.type + item2.name + item2.specs + item2.unit
                        // console.log('valStr', valStr)
                        // console.log('tableStr', tableStr)
                        if (valStr === tableStr) {
                            // console.log('index', index)
                            delete val[index]
                            // this.clientPop('err', '你已经选择了相同规格的物资')
                        }
                    })
                })
                val = val.filter(item => item !== null)
                // 前端显示需要的数据格式
                const arr = []
                val.forEach((item, index) => {
                    arr.push({
                        amount: 0,
                        billId: this.tenderId,
                        changeType: 1,
                        freightPrice: 0,
                        limitPrice: 0,
                        name: '',
                        num: 0,
                        packageId: this.dtlId,
                        recordId: '',
                        specs: '',
                        texture: '',
                        type: '',
                        unit: '',
                        unitPrice: 0,
                        planDetails: '',
                        materialId: '',
                        materialNameId: '',
                        materialTypeId: '',
                        dataType: PlanType2,
                        planId: '',
                        planDtlId: ''
                    })
                    arr[index].name = item.materialName
                    arr[index].specs = item.spec
                    arr[index].unit = item.unit
                    arr[index].type = item.materialClassName
                    arr[index].texture = item.texture
                    arr[index].num = item.planQuantity
                    arr[index].planDetails = JSON.stringify({
                        billid: item.billId,
                        billNo: item.billNo,
                        type: PlanType2
                    })
                    arr[index].materialId = item.materialId
                    arr[index].materialNameId = item.billId
                    arr[index].materialTypeId = item.materialClassId
                    arr[index].planId = item.billId
                    arr[index].planDtlId = item.dtlId
                    // if (item.marketprice) {
                    //     arr[index].limitPrice = item.marketprice
                    // }
                })
                // val.forEach((item, index) => {})
                // console.log(' this.tableData', this.tableData, this.tableData[this.dtlIndex])
                this.tableData[this.dtlIndex].push(...arr)
                console.log('request', this.tableData, this.dtlIndex)
            })
        },
        // 选择基础库
        selectBaseLibrary () {
            if (this.dtlId === '') {
                this.clientPop('err', '请先添加包件')
                return
            }
            // 获取已选择基础id
            const SelectedIDs =
                this.tableData[this.dtlIndex].map(item => item.baseLibraryId).filter(item => item)
                    .length !== 0
                    ? this.tableData[this.dtlIndex]
                        .map(item => item.baseLibraryId)
                        .filter(item => item)
                    : []
            SelectedIDs
            // console.log('SelectedIDs', SelectedIDs)
            selectDataClient({
                SelectServiceToken: '/material/categoryLibrary/queryListByParentClassId2', // 客户端对应方法名
                IsSingleMode: false, // 是否单选 true 单选 false 多选
                SelectedIDs, // 已选中id
                Title: '选择基础库' // 标题
            }).then(val => {
                // this.setSelectedInfo(val)
                // openAppClient('/showSelectedData', '选择结果', function () {})
                // 假数据
                // let val = [
                //     {
                //         billId: '1492034624291868674',
                //         classIdPath: '1492338036615155713/1492338402287161345/1492339386505760770',
                //         className: '一级钢材',
                //         classNamePath: '主要材料/建筑钢材/一级钢材',
                //         materialName: '钢材0004',
                //         spec: '规格4',
                //         unit: 'T'
                //     },
                //     {
                //         billId: '1492034594352926722',
                //         classIdPath: '1492338036615155713/1492338402287161345/1492339386505760770',
                //         className: '一级钢材',
                //         classNamePath: '主要材料/建筑钢材/一级钢材',
                //         materialName: '钢材0003',
                //         spec: '规格3',
                //         unit: 'T'
                //     }
                // ]
                // 过滤基础和计划相同规格的物资
                val.forEach((item, index) => {
                    this.tableData[this.dtlIndex].forEach(item2 => {
                        const valStr =
                            item.classNamePath + item.materialName + item.spec + item.unit
                        const tableStr = item2.type + item2.name + item2.specs + item2.unit
                        if (valStr === tableStr) {
                            // console.log('index', index)
                            delete val[index]
                            // this.clientPop('err', '你已经选择了相同规格的物资')
                        }
                    })
                })
                val = val.filter(item => item !== null)
                // this.setSelectedInfo(val)
                // openAppClient('/showSelectedData', '选择结果', function () {})
                const arr = []
                val.forEach((item, index) => {
                    arr.push({
                        amount: 0,
                        billId: this.tenderId,
                        changeType: 1,
                        freightPrice: 0,
                        limitPrice: 0,
                        name: '',
                        num: 0,
                        packageId: this.dtlId,
                        recordId: '',
                        specs: '',
                        texture: '',
                        type: '',
                        unit: '',
                        unitPrice: 0,
                        planDetails: '',
                        materialId: '',
                        materialNameId: '',
                        materialTypeId: '',
                        dataType: 6,
                        planId: '',
                        planDtlId: ''
                    })
                    arr[index].name = item.materialName
                    arr[index].specs = item.spec
                    arr[index].unit = item.unit
                    arr[index].type = item.classNamePath
                    arr[index].baseLibraryId = item.billId
                    arr[index].materialTypeId = item.classIdPath
                    arr[index].materialNameId = item.billId
                })
                // console.log('this.dtlIndex', this.dtlIndex)
                this.tableData[this.dtlIndex].push(...arr)
                console.log('this.tableData', this.tableData)
                // this.setSelectedInfo(this.tableData)
                // openAppClient('/showSelectedData', '选择结果', function () {})
            })
        },
        handleNodeClick (dtlId) {
            const item = this.detailsData.find(item2 => item2.dtlId === dtlId)
            this.selectDetailState = true
            // 获取清单数据
            this.dtlId = item.dtlId
            // console.log('data', data)
            // console.log('node', node)
            // console.log('el', el)
        },
        // async findByApplyId () {
        //     let data = []
        //     let leftTree = []
        //     if (this.detailsOfProposed.length !== 0) {
        //         data = this.detailsOfProposed
        //     } else {
        //         await applyRequest.bidPackageListByBillId(this.tenderId).then(res => {
        //             data = res
        //             // this.detailsOfProposedArr = res
        //             // this.tableData.forEach(value => {
        //             //     // table显示需要的字段
        //             //     value.subcontractorName =
        //             //         (value.subcontractor[0] && value.subcontractor[0].subcontractorId) || ''
        //             // })
        //             // this.pagination.total = res.totalCount || res.length
        //         })
        //     }
        //     data.forEach(value => {
        //         leftTree.push({ label: value.name })
        //     })
        //     this.detailsOfProposedArr = leftTree
        // },
        openNewPage (name) {
            this.$notify.closeAll()
            if (name === 'tenderList') {
                const params = JSON.stringify({
                    // 正式环境应该不用转换
                    title: '选择清单',
                    url: '',
                    method: 'get',
                    params: { tenderId: this.tenderId }, // 基础id获取包件
                    tableColumnAttr: this.orgSelectTableColumnAttr,
                    tableColumnWidth: this.selectTableColumnWidth,
                    ifPagination: 0
                })
                this.$notify({
                    title: '选择清单',
                    dangerouslyUseHTMLString: true,
                    message: `正式环境：客户端打开新页面<br>
                测试环境：手动打开新页面<br>
                <textarea cols="35" rows="10">http://localhost:8080/selectData?params=${params}</textarea>
                <br><br>
                回调参数：<br>
                <textarea cols="35" rows="3" id="callBackData"></textarea><br>
                <button id="getPopData">执行回调方法</button>
                `,
                    duration: 0
                })
                document.querySelector('#getPopData').addEventListener('click', this.orgGetPopData)
            }
        }
    }
}
</script>
<style lang="scss" scoped>
.ruleMessage {
    margin-bottom: 10px;
    margin-left: 10px;
    color: red;
}

.e-table {
    background: #fff;
}
</style>
